<?php
/**
 * 系統名稱: Lotto 系統
 * 檔案說明: 專案管理-修改
 * $Author$
 * $Id$
 *
 */
include_once("../config.inc.php");


$_LangPath = 'mainthrough';	//語言檔參數，務必放在最前面
$intLID = empty($_data["LottoID"])?1:(int)$_data["LottoID"];
$intSid = $_data[sid];
include_once(__Member_Path."/logincheck_nodb.php");
include_once(__Language_Path."/selectlanguage_member.php");
include_once(__Modules_Path."/ChangeTime.lib.php");
include_once(__Common_Path."/Lotto.inc.php");
include_once(__Common_Path."/SysParam.inc.php");
include_once(__Common_Path."/todaygame/Gamble". $intLID .".inc.php");
include_once(__Common_Path. '/gambletype/GambleType1_'. $intLID. '.inc.php');
include_once (__Common_Path. '/betparam/BetParam_'.$intLID.'.inc.php');
unset($_SESSION["OrderThrough"]);

//找出 Apoint
$intAN = 0;

$_arrGambleType[14][0] -= abs($_arrBetParam[15][$intAN]['StakeJumpRate']);//正碼過關色波賠率比正碼色波小
$arrTOGap = explode(",", $_arrLotto[$intLID]["ThroughOddsGap"]);
$arrBTTOGap = array(12 => array($arrTOGap[0], $arrTOGap[0]), 13 => array($arrTOGap[1], $arrTOGap[1]), 14 => array($arrTOGap[3], $arrTOGap[4], $arrTOGap[5]));

//取得 TodayGame 資料
$arrBT = array(12 => array(0, 1), 13 => array(0, 1), 14 => array(0, 1, 2));
$arrBTOddsPlus = array(12 => 1, 13 => 1, 14 => 0);
foreach($arrBT as $intBT => $arrNum) {
	include(__Common_Path.'/todaygame/TodayGame'. $intLID .'_'.$intBT.'.inc.php');
}


$isStop = false;
if (!is_array($_arrTodayGame) || !is_array($_arrGamble)) {
	$isStop = true;
} else {
	list($intGID, $arrGData) = each($_arrGamble);

	//判斷是否有 Game 時間是否過期
	$GameEndDateTime	= $arrGData["GameDate"] .' '. $arrGData["EndGameTime"];
	$NowDateTime		= date("Y-m-d") .' '. date("H:i:s");

	if ($NowDateTime > $GameEndDateTime) {
		$isStop = true;
	} else {
		$isStop = false;
	}
}

$fp = @file(__Membertemplate_Path."/mainthrough.html");
$fp = implode("", $fp);
$fp = setHTMLCharset($fp);

$fp = str_replace("{SerialNo}", ($isStop)?"0":$arrGData["SerialNo"], $fp);
$fp = str_replace("{ShowGameDate}", $arrGData["GameDate"], $fp);
$fp = str_replace("{ShowGameTime}", $arrGData["GameTime"], $fp);
$fp = str_replace("{sid}", $intSid, $fp);
$fp = str_replace("{UserID}", $_SESSION["Member_Info"] -> ID, $fp);
$fp = str_replace("{LottoID}", $intLID, $fp);
$fp = str_replace("{GambleID}", $intGID, $fp);

foreach($arrBT as $intBT => $arrNum) {
	$flGLine = $_arrGambleType[$intBT][0];

	foreach($arrNum as $intNum){
		for($i = 1; $i <= 6; $i++){
			$arrTGame = $_arrTodayGame[$intGID][$intBT][$i.$intNum];
			$arrTGame["Odds"] += $arrBTTOGap[$intBT][$intNum]*1;

			if($arrTGame["isStopBet"] || $isStop){
				$fp = str_replace("{Odds".$intBT."-".$i.$intNum."}", '<b>'.$_strMainThrough["isStopBet"].'</b>', $fp);
			}else{
				$strLink = ($arrTGame["Odds"] + $arrBTOddsPlus[$intBT] + $flGLine) .'<br /><input type="radio" name="Radio'.$i.'" id="Radio'.$intBT.'-'.$i.$intNum.'" onClick="sendChoiceNumber('.$intBT.', '.$i.$intNum.', '.$arrTGame["OddsID"].')"/>';
				$fp = str_replace("{Odds".$intBT."-".$i.$intNum."}", $strLink, $fp);
			}
		}
	}
}

//以下位置不可上下移動
while(list($k, $v) = each($_strMainThrough)){
	$fp = str_replace("{".$k."}", $v, $fp);
}

//輸出
WebOutputHTML($fp, 1);
?>